package com.sofly.service.impl.group3;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sofly.dao.group3.IOutStockDao;
import com.sofly.dao.group3.IStockManageDao;
import com.sofly.entity.OutStockInfo;
import com.sofly.entity.StockManage;
import com.sofly.service.group3.IOutStockService;
/**
 * 
* <p>Title:IOutStockServiceImpl </p>
* <p>Description: </p>
* <p>Company: </p> 
* @author 苏艳
* @date 上午11:37:58
 */
@Service
public class IOutStockServiceImpl implements IOutStockService {
    
	@Autowired
	private IOutStockDao outStockDao;
	@Autowired
	private IStockManageDao stockManageDao;
	@Override
	public List<OutStockInfo> getOutStockList(int page, int size) {
		// TODO Auto-generated method stub
		return outStockDao.selectOutStockList(page, size);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return outStockDao.selectCount();
	}

	@Override
	public int addOutStock(OutStockInfo outStockInfo) {
		// TODO Auto-generated method stub
		String productId = outStockInfo.getProductId();
		int number = outStockInfo.getAmount();
		StockManage stockManage = stockManageDao.selectStockById(productId);
		int number1 = stockManage.getAmount();
		stockManage.setAmount(number1-number);
		stockManageDao.updateStockManage(stockManage);
		return outStockDao.insertOutStock(outStockInfo);
	}

	@Override
	public int getCount1(String outStockDate) {
		// TODO Auto-generated method stub
		return outStockDao.selectCount1(outStockDate);
	} 

	@Override
	public OutStockInfo getOutStock(String productId) {
		// TODO Auto-generated method stub
		return outStockDao.selectOutStock(productId);
	}

	@Override
	public List<OutStockInfo> getOutStockListByDate(String outStockDate, int page, int size) {
		// TODO Auto-generated method stub
		return outStockDao.selectOutStockListByDate(outStockDate, page, size);
	}

}
